import dayjs from '@/plugins/dayjs'

export const formatSeconds = (value: string) => {
	var theTime: string | number = parseInt(value) // 秒
	var theTime1: string | number = 0 // 分
	var theTime2: string | number = 0 // 小时
	if (theTime > 60) {
		theTime1 = parseInt(String(theTime / 60))
		theTime = parseInt(String(theTime % 60))
		if (theTime1 > 60) {
			theTime2 = parseInt(String(theTime1 / 60))
			theTime1 = parseInt(String(theTime1 % 60))
		}
	}
	if (theTime < 10) {
		theTime = '0' + parseInt(String(theTime))
	}
	var result = '' + theTime
	if (theTime1 >= 0) {
		if (theTime1 < 10) {
			theTime1 = '0' + parseInt(String(theTime1))
		}
		result = '' + theTime1 + ':' + result
	}
	if (theTime2 >= 0) {
		if (theTime2 < 10) {
			theTime2 = '0' + parseInt(String(theTime2))
		}
		result = '' + theTime2 + ':' + result
	}
	return result
}
export const replaceSpaceBk = (str: string) => {
	return str.replace(/&nbsp;/g, ' ')
}
/**终端录像名称时间部分 */
export const buildNameTime = () => {
	var time = dayjs().format('YYYYMMDDHHmmss')
	return time
}
